package com.crealth.model;

import java.io.Serializable;

import com.alibaba.fastjson.JSONObject;

public class ConsumerHouseModel implements Serializable {
	private static final long serialVersionUID = 18420754L;
	
	private int id;
	private int consumerID;
	private int houseType;
	private String houseAddr; 
	private String appraisement;
	private int houseArea;
	private int propertyRight;
	private String installmentBank;
	private int loanTime;
	private String loanSum;
	private String monthPay;
	private String dueSum;
	private int cutPaymentCard;
	private String memo;
	
	public ConsumerHouseModel() {
		appraisement = "";
		loanSum = "";
		monthPay = "";
		dueSum = "";
		memo = "";
		houseType = -1;
		houseAddr = "";
		houseArea = -1;
		propertyRight = -1;
		installmentBank = "";
		loanTime = -1;
		cutPaymentCard = -1;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getConsumerID() {
		return consumerID;
	}
	public void setConsumerID(int consumerID) {
		this.consumerID = consumerID;
	}
	public int getHouseType() {
		return houseType;
	}
	public void setHouseType(int houseType) {
		this.houseType = houseType;
	}
	public String getHouseAddr() {
		return houseAddr;
	}
	public void setHouseAddr(String houseAddr) {
		this.houseAddr = houseAddr;
	}
	public String getAppraisement() {
		return appraisement;
	}
	public void setAppraisement(String appraisement) {
		this.appraisement = appraisement;
	}
	public int getHouseArea() {
		return houseArea;
	}
	public void setHouseArea(int houseArea) {
		this.houseArea = houseArea;
	}
	public int getPropertyRight() {
		return propertyRight;
	}
	public void setPropertyRight(int propertyRight) {
		this.propertyRight = propertyRight;
	}
	public String getInstallmentBank() {
		return installmentBank;
	}
	public void setInstallmentBank(String installmentBank) {
		this.installmentBank = installmentBank;
	}
	public int getLoanTime() {
		return loanTime;
	}
	public void setLoanTime(int loanBank) {
		this.loanTime = loanBank;
	}
	public String getLoanSum() {
		return loanSum;
	}
	public void setLoanSum(String loanSum) {
		this.loanSum = loanSum;
	}
	public String getMonthPay() {
		return monthPay;
	}
	public void setMonthPay(String monthPay) {
		this.monthPay = monthPay;
	}
	public String getDueSum() {
		return dueSum;
	}
	public void setDueSum(String dueSum) {
		this.dueSum = dueSum;
	}
	public int getCutPaymentCard() {
		return cutPaymentCard;
	}
	public void setCutPaymentCard(int cutPaymentCard) {
		this.cutPaymentCard = cutPaymentCard;
	}
	public String getMemo() {
		return memo;
	}
	public void setMemo(String memo) {
		this.memo = memo;
	}
	
	public void parseFromJson(JSONObject jsonData) {
		if (jsonData.containsKey("houseType")) {
			this.houseType = jsonData.getIntValue("houseType");
		}
		if (jsonData.containsKey("houseAddr")) {
			this.houseAddr = jsonData.getString("houseAddr");
		}
		if (jsonData.containsKey("appraisePrice")) {
			this.appraisement = jsonData.getString("appraisePrice");
		}
		if (jsonData.containsKey("area")) {
			this.houseArea = jsonData.getIntValue("area");
		}
		if (jsonData.containsKey("propertyRight")) {
			this.propertyRight = jsonData.getIntValue("propertyRight");
		}
		if (jsonData.containsKey("installmentBank")) {
			this.installmentBank = jsonData.getString("installmentBank");
		}
		if (jsonData.containsKey("loanTime")) {
			this.loanTime = jsonData.getIntValue("loanTime");
		}
		if (jsonData.containsKey("loanMoney")) {
			this.loanSum = jsonData.getString("loanMoney");
		}
		if (jsonData.containsKey("monthPay")) {
			this.monthPay = jsonData.getString("monthPay");
		}
		if (jsonData.containsKey("jieqianMoney")) {
			this.dueSum = jsonData.getString("jieqianMoney");
		}
		if (jsonData.containsKey("koukuangCard")) {
			this.cutPaymentCard = jsonData.getIntValue("koukuangCard");
		}
		if (jsonData.containsKey("houseMemo")) {
			this.memo = jsonData.getString("houseMemo");
		}		
	}
	
	public JSONObject toJSONObject() {
		JSONObject jsonObj = new JSONObject();
		if (houseType >= 0) {
			jsonObj.put("houseType", houseType);
		}
		if (houseAddr.length() >= 0) {
			jsonObj.put("houseAddr", houseAddr);
		}
		if (appraisement != null && appraisement.length() > 0) {
			jsonObj.put("appraisePrice", appraisement);
		}
		if (houseArea > 0) {
			jsonObj.put("area", houseArea);
		}
		if (propertyRight >= 0) {
			jsonObj.put("propertyRight", propertyRight);
		}
		if (installmentBank.length() >= 0) {
			jsonObj.put("installmentBank", installmentBank);
		}
		if (loanTime >= 0) {
			jsonObj.put("loanTime", loanTime);
		}
		if (loanSum != null && loanSum.length() > 0) {
			jsonObj.put("loanMoney", loanSum);
		}
		if (monthPay != null && monthPay.length() > 0) {
			jsonObj.put("monthPay", monthPay);
		}
		if (dueSum != null && dueSum.length() > 0) {
			jsonObj.put("jieqianMoney", dueSum);
		}
		if (cutPaymentCard >= 0) {
			jsonObj.put("koukuangCard", cutPaymentCard);
		}
		if (memo != null && memo.length() > 0) {
			jsonObj.put("houseMemo", memo);
		}
		
		return jsonObj;
	}
		
}
